﻿/*
LineChart：
dom：图表渲染容器
xData：x轴
yData:数据
linetitle：标题（默认值为空）
maxy：最大值（与plotLines配合使用）
plotLines:基准线
*/

function BasicChart(lineCharto) {
    this.lineSChartDom = lineCharto.dom;
    this.linetitle = lineCharto.linetitle ? lineCharto.linetitle : " ";
    this.linetitleD = lineCharto.linetitleD ? lineCharto.linetitleD :"";
    this.linetitleDClass = lineCharto.linetitleDClass ? lineCharto.linetitleDClass :"";
    this.xData = lineCharto.xData;
    this.yData = lineCharto.yData;
    this.maxy = lineCharto.maxy ? lineCharto.maxy : null;
    this.plotLines = lineCharto.plotLines != null ? lineCharto.plotLines : "null";
    this.plotlineid = lineCharto.plotlineid ? lineCharto.plotlineid : "plotline";
    this.enabled = lineCharto.enabled != null ? lineCharto.enabled : true;
    this.xEnabled = lineCharto.xEnabled != null ? lineCharto.xEnabled : false;
    this.reversed = lineCharto.reversed != null ? lineCharto.reversed : false;
    this.color = lineCharto.color;

    var self = this;

  
    return new Highcharts.Chart({
        chart: {
            renderTo: self.lineSChartDom,
            type: 'bar'
        },
        title: {  text:null},
        subtitle: {
            text: ''
        },
        xAxis: [{
            lineWidth: 0,
            categories: self.xData,
            labels: {
                tickPixelInterval: 94,
                staggerLines:0,
                lineWidth:0,
                style: {
                    color: '#414C59',
                },
                x:45,//调节x偏移
                //y:-35,//调节y偏移
                //rotation:25//调节倾斜角度偏移
                enabled:self.xEnabled
            },
            opposite:true,
            x:10
        }],
        yAxis: {
            gridLineWidth: 0,
            lineWidth: 0,
            minPadding:0,
            startOnTick:false,
            lineColor: '#6a6a6a',
            max: self.maxy,
            min: 0,
            title: {
               text:null
            },
            labels:{
                enabled:false
            },
            reversed:self.reversed,
        },
        colors: self.color,
        plotOptions: {
            bar: {
                dataLabels: {
                    enabled: true,
                    // allowOverlap: true,
                    // align:'right',
                    // x:-100
                }
            },
            series: {
                animation: false,
                borderWidth: 0,
                shadow: false
            },
        },
        credits: {
            enabled: false
        },
        tooltip: {
            borderWidth: 0,
            formatter: function () {
                // return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y;
                return '<b>' + this.series.name + '</b><br/>' + this.y;
            }
        },
        legend: {
            align: 'center',
            layout: 'vertical',
            verticalAlign: 'top',
            floating: false,
            // backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
            borderWidth: 0,
            enabled: self.enabled,
            shadow: false
        },
        series: self.yData
    });
}
